package com.googlecode.perfectable.visuable.renderer.xml;

import static com.google.common.base.Preconditions.checkNotNull;

import javax.xml.stream.XMLStreamWriter;

import com.googlecode.perfectable.visuable.renderer.ElementRenderer;
import com.googlecode.perfectable.visuable.renderer.VisualRenderer;

// MARK check if multiple element renderers are created
public class XmlVisualRenderer implements VisualRenderer {
	private final XMLStreamWriter xmlWriter;
	
	public XmlVisualRenderer(XMLStreamWriter xmlWriter) {
		this.xmlWriter = checkNotNull(xmlWriter);
	}
	
	@Override
	public ElementRenderer element(String elementName) {
		return createElementRenderer(this.xmlWriter, elementName);
	}
	
	protected XmlElementRenderer createElementRenderer(@SuppressWarnings("hiding") XMLStreamWriter xmlWriter,
			String elementName) {
		return new XmlElementRenderer(xmlWriter, elementName);
	}
	
	@Override
	public void close() {
		// nothing done
	}
	
}
